package org.example.flink.pojo;

import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;

import java.util.Arrays;

/**
 * @Author: tang
 * @Description:
 * @Date 2025/2/16 15:03
 */
public class FlinkPojo {

    public static void main(String[] args) throws Exception{
        StreamExecutionEnvironment environment = StreamExecutionEnvironment.getExecutionEnvironment();
        environment.fromCollection(
                Arrays.asList(
                        new WaterSensor("1","11", 10),
                        new WaterSensor("2","22", 20),
                        new WaterSensor("3","33",30)
                )
        ).flatMap((WaterSensor waterSensor, Collector<String> collector) -> {
            collector.collect(waterSensor.id);
        }).returns(Types.STRING)
                .print();

        environment.execute();
    }

}
